<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Example</title>
    <link rel="stylesheet" href="./../../base/bass.css"/>
    <style>
    </style>
</head>
<body>
</body>
<script>
    window.main = function () {

    }
    window.needLogin = true;
    window.beforeLoadApp = function () {
        if (window.needLogin) {
            Requests.getToken()
                .then(token => {
                    if (token === '') {
                        alert("请先登录");
                        location.href = './../Login/index.html';
                    } else {
                        Requests.checkAdmin(token)
                            .then(msg => {
                                if (msg === '') {
                                    window.main();
                                } else {
                                    alert(msg);
                                    location.href = './../login/index.index';
                                }
                            })
                    }
                });
        } else {
            window.main();
        }
    }
    let sc = document.createElement('script');
    sc.src = "./../../base/utils/loadFiles.js";
    sc.onload = function () {
        let files = [
            { link: './../../base/utils/requests.js',text: '' },
            { link: './../../base/loading/loading.css',text: '' },
            { link: './../../base/loading/Loading.js',text: 'Loading JS' },
            { link: './../../base/dialog/Dialog.js',text: '' },
            { link: './../../base/icons/icon.css',text: '' },
            { link: './../../base/icons/Icons.js',text: '' },
            { link: './../../base/card/Card.js',text: '' },
            { link: './../../base/Slider/jquery.1.2.6.js',text: '' },
            { link: './../../base/Table/Table.js',text: '' },
        ];
        window.loading = null;
        if (window.parent !== window) {
            if (window.parent.loading) {
                window.loading = window.parent.loading;
                files.shift();
                files.shift();
            }
        }
        let lf = new LoadFiles();
        lf.addFile(files).load(o => {
            if (!o.start) {
                o.next();
                if (o.over) {
                    window.loading.hide();
                    window.beforeLoadApp();
                } else if (o.file.text === 'Loading JS') {
                    window.loading = new Loading();
                }
            }
        });
    }
    document.head.append(sc);
</script>
</html>
